package com.neusoft.yuejian_01.model;

import com.neusoft.yuejian_01.base.BaseModel;
import com.neusoft.yuejian_01.javabean.GiftBean;
import com.neusoft.yuejian_01.listener.RetrofitListener;
import com.neusoft.yuejian_01.service.GiftService;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by MARIA on 2017/10/12.
 */

public class GiftModel extends BaseModel {
    //所有奖品列表
    public void getGiftlist(final RetrofitListener listener) {
        this.flag = Const.GiftList;
        GiftService giftService = retrofit.create(GiftService.class);
        Call<List<GiftBean>> call = giftService.getGiftlist();
        Callback<List<GiftBean>> callback = new Callback<List<GiftBean>>() {
            @Override
            public void onResponse(Call<List<GiftBean>> call, Response<List<GiftBean>> response) {
                List<GiftBean> giftBean = response.body();
                listener.onSuccess(giftBean,flag);
            }
            @Override
            public void onFailure(Call<List<GiftBean>> call, Throwable t) {
                listener.onFail();
            }
        };
        call.enqueue(callback);
    }



}


